package edu.nmt.cs.cse326.team4.crap;

import java.io.Serializable;
import java.util.Date;

/**
 * Represents a comment. A comment includes the author, the comment, and a date timestamp.
 * Toilets contain a list of comments, so no reference to the toilet is made. This might need to be changed, depending on how the server stores toilets.
 * @author Matthew Broomfield
 */
public class Comment implements Serializable{

	private static final long serialVersionUID = 1L;
	
	/**
	 * The author of the comment
	 */
	private String author = "Anonymous";
	
	/**
	 * The comment itself
	 */
	private String comment = "";
	
	/**
	 * A timestamp when this comment was made
	 */
	private Date timeStamp = new Date();
	
	/**
	 * the rating of the toilet, given by the author
	 */
	private float rating = (float) 0.0;
	
	/**
	 * Creates the comment with an Anonymous user and the current time
	 * @param comment the comment
	 */
	public Comment(String comment){
		setComment(comment);
	}
	
	/**
	 * Creates the comment with an Anonymous user
	 * @param comment the comment
	 * @param timeStamp the time the comment was made
	 */
	public Comment(String comment, Date timeStamp){
		this(comment);
		setTimeStamp(timeStamp);
	}
	
	/**
	 * Creates the comment
	 * @param author the author of the comment
	 * @param comment the comment
	 * @param timeStamp the time the comment was made
	 */
	public Comment(String author, String comment, Date timeStamp, float rating){
		setAuthor(author);
		setTimeStamp(timeStamp);
		setRating(rating);
		setComment(comment);
	}
	
	/**
	 * Gets the author
	 * @return the author of the comment
	 */
	public String getAuthor(){
		return author;
	}
	
	/**
	 * Sets the author
	 * @param author the new author of the comment
	 */
	public void setAuthor(String author) {
		this.author = author;
	}
	
	/**
	 * Gets the actual comment
	 * @return the comment
	 */
	public String getComment(){
		return comment;
	}
	
	/**
	 * Sets a new comment
	 * @param comment the new comment
	 */
	public void setComment(String comment) {
		this.comment = comment;
	}
	
	/**
	 * Gets the Date object which represents the time the comment was made
	 * @return the time the comment was made
	 */
	public Date getTimeStamp(){
		return timeStamp;
	}
	
	/**
	 * Sets the time the comment was made
	 * @param timeStamp the new timeStamp for the comment
	 */
	public void setTimeStamp(Date timeStamp) {
		this.timeStamp = timeStamp;
	}
	
	/**
	 * Gets the author's rating of the toilet
	 * @return the rating
	 */
	public float getRating() {
        return rating;
	}
	
	/**
	 * Sets the author's rating of the toilet
	 * @param rating the new rating
	 */
	public void setRating(float rating) {
	        this.rating = rating;
	}
}

